﻿//==================================================================
// Copyright (C) 2011 深圳市中旭企业管理股份有限公司
// 文件名: CrmPay.cs
// 作 者：代码自动生成
// 日 期：2013-3-14 16:25:03
// 描 述：
// 版 本：1.00
// 修改历史纪录
// 版 本  修改时间      修改人            修改内容
// 1.00             
//==================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.Text;
using Csla;
using lite;
using Csla.Validation;
using Csla.Data;
using System.Data.SqlClient;
using ZX.DAL;
using OpenExpressApp.ORM;

namespace ZX.CRM.Library
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    [Table(Name = "CrmPay")]
    [ZX.DBModule.Table("CrmPay", "ID")]
    public class CrmPay : ZX.DBModule.BaseEntity
    {

        #region Business Methods 业务方法

        /// <summary>
        /// ID
        /// </summary>
        private static PropertyInfo<Guid> IDProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("ID"));
        [DataObjectField(true, true)]
        [Column, PK]
        public Guid ID
        {
            get { return GetProperty(IDProperty); }
            set { SetProperty(IDProperty, value); }
        }

        /// <summary>
        /// 编码
        /// </summary>
        private static PropertyInfo<string> CodeProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("Code"));
        [Column]
        public string Code
        {
            get { return GetProperty(CodeProperty); }
            set { SetProperty(CodeProperty, value); }
        }
        /// <summary>
        /// 客户ID
        /// </summary>
        private static PropertyInfo<Guid> CustomerIdProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("CustomerId"));
        [Column]
        public Guid CustomerId
        {
            get { return GetProperty(CustomerIdProperty); }
            set { SetProperty(CustomerIdProperty, value); }
        }
        /// <summary>
        /// 币别ID
        /// </summary>
        private static PropertyInfo<Guid> ValutaIDProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("ValutaID"));
        [Column]
        public Guid ValutaID
        {
            get { return GetProperty(ValutaIDProperty); }
            set { SetProperty(ValutaIDProperty, value); }
        }
        /// <summary>
        /// 业绩归属
        /// </summary>
        private static PropertyInfo<Guid> DeptIdProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("DeptId"));
        [Column]
        public Guid DeptId
        {
            get { return GetProperty(DeptIdProperty); }
            set { SetProperty(DeptIdProperty, value); }
        }
        /// <summary>
        /// 汇率ID
        /// </summary>
        private static PropertyInfo<Guid> PillIDProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("PillID"));
        [Column]
        public Guid PillID
        {
            get { return GetProperty(PillIDProperty); }
            set { SetProperty(PillIDProperty, value); }
        }

        /// <summary>
        /// 列表
        /// </summary>
        private static PropertyInfo<string> ProduectListProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("ProduectList"));
        //[Column]
        public string ProduectList
        {
            get { return GetProperty(ProduectListProperty); }
            set { SetProperty(ProduectListProperty, value); }
        }
        /// <summary>
        /// 发票号
        /// </summary>
        private static PropertyInfo<string> InvoiceNumProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("InvoiceNum"));
        [Column]
        public string InvoiceNum
        {
            get { return GetProperty(InvoiceNumProperty); }
            set { SetProperty(InvoiceNumProperty, value); }
        }
        /// <summary>
        /// 缴款单状态ID
        /// </summary>
        private static PropertyInfo<Guid> StateProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("State"));
        [Column]
        public Guid State
        {
            get { return GetProperty(StateProperty); }
            set { SetProperty(StateProperty, value); }
        }
        /// <summary>
        /// 缴款日期
        /// </summary>
        private static PropertyInfo<DateTime> DateProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<DateTime>("Date"));
        [Column]
        public DateTime Date
        {
            get { return GetProperty(DateProperty); }
            set { SetProperty(DateProperty, value); }
        }
        /// <summary>
        /// 说明
        /// </summary>
        private static PropertyInfo<string> ExplainProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("Explain"));
        [Column]
        public string Explain
        {
            get { return GetProperty(ExplainProperty); }
            set { SetProperty(ExplainProperty, value); }
        }
        /// <summary>
        /// 操作员编号
        /// </summary>
        private static PropertyInfo<Guid> AddUserProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("AddUser"));
        [Column]
        public Guid AddUser
        {
            get { return GetProperty(AddUserProperty); }
            set { SetProperty(AddUserProperty, value); }
        }
        /// <summary>
        /// 新增时间
        /// </summary>
        private static PropertyInfo<DateTime> AddtimeProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<DateTime>("Addtime"));
        [Column]
        public DateTime Addtime
        {
            get { return GetProperty(AddtimeProperty); }
            set { SetProperty(AddtimeProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> WorkFlowIdProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("WorkFlowId"));
        [Column]
        public string WorkFlowId
        {
            get { return GetProperty(WorkFlowIdProperty); }
            set { SetProperty(WorkFlowIdProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> WorkFlowInsIdProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("WorkFlowInsId"));
        [Column]
        public string WorkFlowInsId
        {
            get { return GetProperty(WorkFlowInsIdProperty); }
            set { SetProperty(WorkFlowInsIdProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> WorkTaskIdProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("WorkTaskId"));
        [Column]
        public string WorkTaskId
        {
            get { return GetProperty(WorkTaskIdProperty); }
            set { SetProperty(WorkTaskIdProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> WorkTaskInsIdProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("WorkTaskInsId"));
        [Column]
        public string WorkTaskInsId
        {
            get { return GetProperty(WorkTaskInsIdProperty); }
            set { SetProperty(WorkTaskInsIdProperty, value); }
        }
        /// <summary>
        /// 指定人用户名
        /// </summary>
        private static PropertyInfo<string> CheckUserProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("CheckUser"));
        [Column]
        public string CheckUser
        {
            get { return GetProperty(CheckUserProperty); }
            set { SetProperty(CheckUserProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<DateTime> PayDateProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<DateTime>("PayDate"));
        [Column]
        public DateTime PayDate
        {
            get { return GetProperty(PayDateProperty); }
            set { SetProperty(PayDateProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<DateTime> FactPayDateProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<DateTime>("FactPayDate"));
        [Column]
        public DateTime FactPayDate
        {
            get { return GetProperty(FactPayDateProperty); }
            set { SetProperty(FactPayDateProperty, value); }
        }
        /// <summary>
        /// 计算佣金时间
        /// </summary>
        private static PropertyInfo<string> CommissionDateProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("CommissionDate"));
        [Column]
        public string CommissionDate
        {
            get { return GetProperty(CommissionDateProperty); }
            set { SetProperty(CommissionDateProperty, value); }
        }
        /// <summary>
        /// 计算人
        /// </summary>
        private static PropertyInfo<Guid> CommissionUserIDProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("CommissionUserID"));
        [Column]
        public Guid CommissionUserID
        {
            get { return GetProperty(CommissionUserIDProperty); }
            set { SetProperty(CommissionUserIDProperty, value); }
        }
        /// <summary>
        /// 计算佣金时间
        /// </summary>
        private static PropertyInfo<DateTime> CommissionTimeProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<DateTime>("CommissionTime"));
        [Column]
        public DateTime CommissionTime
        {
            get { return GetProperty(CommissionTimeProperty); }
            set { SetProperty(CommissionTimeProperty, value); }
        }
        /// <summary>
        /// 佣金金额
        /// </summary>
        private static PropertyInfo<decimal> CommissionPayProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<decimal>("CommissionPay"));
        [Column]
        public decimal CommissionPay
        {
            get { return GetProperty(CommissionPayProperty); }
            set { SetProperty(CommissionPayProperty, value); }
        }
        /// <summary>
        /// 是否发放佣金(0:没有  1:有  2:)
        /// </summary>
        private static PropertyInfo<int> CommissionStateProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<int>("CommissionState"));
        [Column]
        public int CommissionState
        {
            get { return GetProperty(CommissionStateProperty); }
            set { SetProperty(CommissionStateProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> ReceiptProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("Receipt"));
        [Column]
        public string Receipt
        {
            get { return GetProperty(ReceiptProperty); }
            set { SetProperty(ReceiptProperty, value); }
        }
        /// <summary>
        /// 备用1
        /// </summary>
        private static PropertyInfo<string> EXP1Property = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("EXP1"));
        [Column]
        public string EXP1
        {
            get { return GetProperty(EXP1Property); }
            set { SetProperty(EXP1Property, value); }
        }
        /// <summary>
        /// 备用2
        /// </summary>
        private static PropertyInfo<string> EXP2Property = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("EXP2"));
        [Column]
        public string EXP2
        {
            get { return GetProperty(EXP2Property); }
            set { SetProperty(EXP2Property, value); }
        }
        /// <summary>
        /// 备用3
        /// </summary>
        private static PropertyInfo<string> EXP3Property = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("EXP3"));
        [Column]
        public string EXP3
        {
            get { return GetProperty(EXP3Property); }
            set { SetProperty(EXP3Property, value); }
        }
        /// <summary>
        /// 备用4
        /// </summary>
        private static PropertyInfo<string> EXP4Property = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("EXP4"));
        [Column]
        public string EXP4
        {
            get { return GetProperty(EXP4Property); }
            set { SetProperty(EXP4Property, value); }
        }
        /// <summary>
        /// 发票金额
        /// </summary>
        private static PropertyInfo<decimal> InvoiceMoneyProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<decimal>("InvoiceMoney"));
        [Column]
        public decimal InvoiceMoney
        {
            get { return GetProperty(InvoiceMoneyProperty); }
            set { SetProperty(InvoiceMoneyProperty, value); }
        }
        /// <summary>
        /// 发票审核人
        /// </summary>
        private static PropertyInfo<Guid> InvoiceAddUserProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("InvoiceAddUser"));
        [Column]
        public Guid InvoiceAddUser
        {
            get { return GetProperty(InvoiceAddUserProperty); }
            set { SetProperty(InvoiceAddUserProperty, value); }
        }
        /// <summary>
        /// 发票添加时间
        /// </summary>
        private static PropertyInfo<DateTime> InvoiceAddTimeProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<DateTime>("InvoiceAddTime"));
        [Column]
        public DateTime InvoiceAddTime
        {
            get { return GetProperty(InvoiceAddTimeProperty); }
            set { SetProperty(InvoiceAddTimeProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> IsFinishProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("IsFinish"));
        [Column]
        public string IsFinish
        {
            get { return GetProperty(IsFinishProperty); }
            set { SetProperty(IsFinishProperty, value); }
        }
        /// <summary>
        /// 是否15个月内成交
        /// </summary>
        private static PropertyInfo<string> IsFifteenMonthProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("IsFifteenMonth"));
        [Column]
        public string IsFifteenMonth
        {
            get { return GetProperty(IsFifteenMonthProperty); }
            set { SetProperty(IsFifteenMonthProperty, value); }
        }
        /// <summary>
        /// 是否项目结项6个月内续签（不包含产品类、俱乐部）
        /// </summary>
        private static PropertyInfo<string> IsProjectOverProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("IsProjectOver"));
        [Column]
        public string IsProjectOver
        {
            get { return GetProperty(IsProjectOverProperty); }
            set { SetProperty(IsProjectOverProperty, value); }
        }
        /// <summary>
        /// 是否总裁内训
        /// </summary>
        private static PropertyInfo<string> IsCEOInnerTrainProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("IsCEOInnerTrain"));
        [Column]
        public string IsCEOInnerTrain
        {
            get { return GetProperty(IsCEOInnerTrainProperty); }
            set { SetProperty(IsCEOInnerTrainProperty, value); }
        }
        /// <summary>
        /// 是否内训中续签内训
        /// </summary>
        private static PropertyInfo<string> IsInnerTrainSianProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("IsInnerTrainSian"));
        [Column]
        public string IsInnerTrainSian
        {
            get { return GetProperty(IsInnerTrainSianProperty); }
            set { SetProperty(IsInnerTrainSianProperty, value); }
        }
        /// <summary>
        /// 是否一推现场或4个月内完款
        /// </summary>
        private static PropertyInfo<string> IsFisrtSaleProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("IsFisrtSale"));
        [Column]
        public string IsFisrtSale
        {
            get { return GetProperty(IsFisrtSaleProperty); }
            set { SetProperty(IsFisrtSaleProperty, value); }
        }
        /// <summary>
        /// 复核人
        /// </summary>
        private static PropertyInfo<Guid> CheckAddUserProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("CheckAddUser"));
        [Column]
        public Guid CheckAddUser
        {
            get { return GetProperty(CheckAddUserProperty); }
            set { SetProperty(CheckAddUserProperty, value); }
        }
        /// <summary>
        /// 复核时间
        /// </summary>
        private static PropertyInfo<DateTime> CheckAddTimeProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<DateTime>("CheckAddTime"));
        [Column]
        public DateTime CheckAddTime
        {
            get { return GetProperty(CheckAddTimeProperty); }
            set { SetProperty(CheckAddTimeProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> IsCheckProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("IsCheck"));
        [Column]
        public string IsCheck
        {
            get { return GetProperty(IsCheckProperty); }
            set { SetProperty(IsCheckProperty, value); }
        }
        /// <summary>
        /// 快递号
        /// </summary>
        private static PropertyInfo<string> ExpressNoProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("ExpressNo"));
        [Column]
        public string ExpressNo
        {
            get { return GetProperty(ExpressNoProperty); }
            set { SetProperty(ExpressNoProperty, value); }
        }
        /// <summary>
        /// 是否复核
        /// </summary>
        private static PropertyInfo<string> IsAgainCheckProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("IsAgainCheck"));
        [Column]
        public string IsAgainCheck
        {
            get { return GetProperty(IsAgainCheckProperty); }
            set { SetProperty(IsAgainCheckProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> AgainCheckUserProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("AgainCheckUser"));
        [Column]
        public Guid AgainCheckUser
        {
            get { return GetProperty(AgainCheckUserProperty); }
            set { SetProperty(AgainCheckUserProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<DateTime> AgainCheckTimeProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<DateTime>("AgainCheckTime"));
        [Column]
        public DateTime AgainCheckTime
        {
            get { return GetProperty(AgainCheckTimeProperty); }
            set { SetProperty(AgainCheckTimeProperty, value); }
        }
        /// <summary>
        /// 总监
        /// </summary>
        private static PropertyInfo<Guid> CZNameProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("CZName"));
        [Column]
        public Guid CZName
        {
            get { return GetProperty(CZNameProperty); }
            set { SetProperty(CZNameProperty, value); }
        }
        /// <summary>
        /// 分总
        /// </summary>
        private static PropertyInfo<Guid> FZNameProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("FZName"));
        [Column]
        public Guid FZName
        {
            get { return GetProperty(FZNameProperty); }
            set { SetProperty(FZNameProperty, value); }
        }
        /// <summary>
        /// 团队
        /// </summary>
        private static PropertyInfo<Guid> CTeamProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("CTeam"));
        [Column]
        public Guid CTeam
        {
            get { return GetProperty(CTeamProperty); }
            set { SetProperty(CTeamProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> CJNameProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("CJName"));
        [Column]
        public Guid CJName
        {
            get { return GetProperty(CJNameProperty); }
            set { SetProperty(CJNameProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> IsYjProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("IsYj"));
        [Column]
        public string IsYj
        {
            get { return GetProperty(IsYjProperty); }
            set { SetProperty(IsYjProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<DateTime> BankDateProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<DateTime>("BankDate"));
        [Column]
        public DateTime BankDate
        {
            get { return GetProperty(BankDateProperty); }
            set { SetProperty(BankDateProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<Guid> AccountFromProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<Guid>("AccountFrom"));
        [Column]
        public Guid AccountFrom
        {
            get { return GetProperty(AccountFromProperty); }
            set { SetProperty(AccountFromProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        private static PropertyInfo<string> PayAddressProperty = RegisterProperty(typeof(CrmPay), new PropertyInfo<string>("PayAddress"));
        [Column]
        public string PayAddress
        {
            get { return GetProperty(PayAddressProperty); }
            set { SetProperty(PayAddressProperty, value); }
        }
        #endregion

        #region Validation Rules 验证规则
        //将验证规则与业务对象的属性联系在一起
        protected override void AddBusinessRules()
        {
            //AddRule的第一个参数是委托变量，也就是说是方法的变量
            ValidationRules.AddRule(CommonRules.StringRequired, "Code");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Code", 15));
            ValidationRules.AddRule(CommonRules.StringRequired, "InvoiceNum");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("InvoiceNum", 100));
            ValidationRules.AddRule(CommonRules.StringRequired, "Explain");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Explain", 200));
            ValidationRules.AddRule(CommonRules.StringRequired, "WorkFlowId");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("WorkFlowId", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "WorkFlowInsId");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("WorkFlowInsId", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "WorkTaskId");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("WorkTaskId", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "WorkTaskInsId");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("WorkTaskInsId", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "CheckUser");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("CheckUser", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "CommissionDate");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("CommissionDate", 20));
            ValidationRules.AddRule(CommonRules.StringRequired, "Receipt");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("Receipt", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "EXP1");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("EXP1", 40));
            ValidationRules.AddRule(CommonRules.StringRequired, "EXP2");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("EXP2", 40));
            ValidationRules.AddRule(CommonRules.StringRequired, "EXP3");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("EXP3", 40));
            ValidationRules.AddRule(CommonRules.StringRequired, "EXP4");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("EXP4", 40));
            ValidationRules.AddRule(CommonRules.StringRequired, "IsFinish");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("IsFinish", 1));
            ValidationRules.AddRule(CommonRules.StringRequired, "IsFifteenMonth");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("IsFifteenMonth", 1));
            ValidationRules.AddRule(CommonRules.StringRequired, "IsProjectOver");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("IsProjectOver", 1));
            ValidationRules.AddRule(CommonRules.StringRequired, "IsCEOInnerTrain");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("IsCEOInnerTrain", 1));
            ValidationRules.AddRule(CommonRules.StringRequired, "IsInnerTrainSian");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("IsInnerTrainSian", 1));
            ValidationRules.AddRule(CommonRules.StringRequired, "IsFisrtSale");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("IsFisrtSale", 1));
            ValidationRules.AddRule(CommonRules.StringRequired, "IsCheck");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("IsCheck", 1));
            ValidationRules.AddRule(CommonRules.StringRequired, "ExpressNo");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("ExpressNo", 50));
            ValidationRules.AddRule(CommonRules.StringRequired, "IsAgainCheck");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("IsAgainCheck", 1));
            ValidationRules.AddRule(CommonRules.StringRequired, "IsYj");
            ValidationRules.AddRule(CommonRules.StringMaxLength, new Csla.Validation.CommonRules.MaxLengthRuleArgs("IsYj", 1));
            //base.AddBusinessRules();
        }
        #endregion

        #region Factory Methods 工厂方法

        public CrmPay() { }

        public static CrmPay New()
        {
            return DataPortal.Create<CrmPay>();
        }
        public static CrmPay Get(Guid ID)
        {
            return DataPortal.Fetch<CrmPay>(new SingleLazyCriteria<CrmPay, Guid>(ID, false));
        }
        public static void Delete(Guid ID)
        {
            DataPortal.Delete(ID);
        }

        //public override CrmPay Save()
        //{
        //return base.Save();
        //}
        #endregion

        #region Data Access 数据访问
        //由于DataPortal_create中没有对数据库的访问，所有标记了Runlocal特性，使得该方法只需在本地运行即可
        //如果代码中有访问数据库的方法，那么就不要用这个特性，使数据门户可以根据情况将此方法的运行选择在应用服务器还是本地
        [RunLocal()]
        protected override void DataPortal_Create()
        {
            //在此调用CheckRules对所有的属性进行验证规则的检查，这样检查只运行一次。
            ValidationRules.CheckRules();
        }


        //可以看到此方法没有标记任何特性
        //此方法要访问数据库所以不能标记本地，由于她没有任何数据库更新操作所以也无需事务性的保护
        //此方法调用结束后会隐含的调用MarkOld（）方法
        private void DataPortal_Fetch(Guid ID)
        {
            //通过连接字符串建立SQL连接对象，Using符号代表，范围释放的意思，SqlConnection对象会在此范围后被释放掉
            using (var ctx = ConnectionManager<SqlConnection>.GetManager(ConnectionStringNames))
            {
                IDb db = DbFactory.Instance.GetDb(ctx.Connection);
                IQuery q = db.Query();
                q.Constrain("ID").Equal(ID);
                var data = db.Select<CrmPay>(q)[0];
                LoadProperty(IDProperty, data.ID);
                LoadProperty(CodeProperty, data.Code);
                LoadProperty(CustomerIdProperty, data.CustomerId);
                LoadProperty(ValutaIDProperty, data.ValutaID);
                LoadProperty(DeptIdProperty, data.DeptId);
                LoadProperty(PillIDProperty, data.PillID);
                LoadProperty(InvoiceNumProperty, data.InvoiceNum);
                LoadProperty(StateProperty, data.State);
                LoadProperty(DateProperty, data.Date);
                LoadProperty(ExplainProperty, data.Explain);
                LoadProperty(AddUserProperty, data.AddUser);
                LoadProperty(AddtimeProperty, data.Addtime);
                LoadProperty(WorkFlowIdProperty, data.WorkFlowId);
                LoadProperty(WorkFlowInsIdProperty, data.WorkFlowInsId);
                LoadProperty(WorkTaskIdProperty, data.WorkTaskId);
                LoadProperty(WorkTaskInsIdProperty, data.WorkTaskInsId);
                LoadProperty(CheckUserProperty, data.CheckUser);
                LoadProperty(PayDateProperty, data.PayDate);
                LoadProperty(FactPayDateProperty, data.FactPayDate);
                LoadProperty(CommissionDateProperty, data.CommissionDate);
                LoadProperty(CommissionUserIDProperty, data.CommissionUserID);
                LoadProperty(CommissionTimeProperty, data.CommissionTime);
                LoadProperty(CommissionPayProperty, data.CommissionPay);
                LoadProperty(CommissionStateProperty, data.CommissionState);
                LoadProperty(ReceiptProperty, data.Receipt);
                LoadProperty(EXP1Property, data.EXP1);
                LoadProperty(EXP2Property, data.EXP2);
                LoadProperty(EXP3Property, data.EXP3);
                LoadProperty(EXP4Property, data.EXP4);
                LoadProperty(InvoiceMoneyProperty, data.InvoiceMoney);
                LoadProperty(InvoiceAddUserProperty, data.InvoiceAddUser);
                LoadProperty(InvoiceAddTimeProperty, data.InvoiceAddTime);
                LoadProperty(IsFinishProperty, data.IsFinish);
                LoadProperty(IsFifteenMonthProperty, data.IsFifteenMonth);
                LoadProperty(IsProjectOverProperty, data.IsProjectOver);
                LoadProperty(IsCEOInnerTrainProperty, data.IsCEOInnerTrain);
                LoadProperty(IsInnerTrainSianProperty, data.IsInnerTrainSian);
                LoadProperty(IsFisrtSaleProperty, data.IsFisrtSale);
                LoadProperty(CheckAddUserProperty, data.CheckAddUser);
                LoadProperty(CheckAddTimeProperty, data.CheckAddTime);
                LoadProperty(IsCheckProperty, data.IsCheck);
                LoadProperty(ExpressNoProperty, data.ExpressNo);
                LoadProperty(IsAgainCheckProperty, data.IsAgainCheck);
                LoadProperty(AgainCheckUserProperty, data.AgainCheckUser);
                LoadProperty(AgainCheckTimeProperty, data.AgainCheckTime);
                LoadProperty(CZNameProperty, data.CZName);
                LoadProperty(FZNameProperty, data.FZName);
                LoadProperty(CTeamProperty, data.CTeam);
                LoadProperty(ProduectListProperty, data.ProduectList);
                LoadProperty(CJNameProperty, data.CJName);
                LoadProperty(IsYjProperty, data.IsYj);
                LoadProperty(BankDateProperty, data.BankDate);
                LoadProperty(AccountFromProperty, data.AccountFrom);
                LoadProperty(PayAddressProperty, data.PayAddress);
            }
        }

        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_DeleteSelf()
        {
            //依然是调用下面的方法删除的，只是他此时可以获得自己的Id
            DataPortal_Delete(IDProperty);
        }
        #endregion

    }
}

